import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from "path";
import VueSetupExtend from 'vite-plugin-vue-setup-extend'; // 支持name属性的使用
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { VantResolver } from 'unplugin-vue-components/resolvers';

import Unocss from 'unocss/vite';
import { presetUno, presetAttributify, presetIcons } from 'unocss'
export default defineConfig({
	base: './',
	resolve: { // 这里配置需要注意：Vite新版本resolve配置改为对象形式，如下：
		alias: [
			{
				find: '@',
				replacement: resolve(__dirname, "src"),
			},
		]
	},
	plugins: [
		vue(),
		Unocss({ // 使用Unocss
			presets: [
				presetUno(),
				presetAttributify(),
				presetIcons()],
			// 这里可以使用自定义的
			rules:[
				['m-1', { margin: '100px' }] // 这里可以自定义
			]
		}),
		VueSetupExtend(),
		AutoImport({
			imports:['vue','vue-router'],
			resolvers: [ElementPlusResolver(),VantResolver()]
		}),
		Components({
			dts:true,
			dirs:['src'],
			resolvers: [ElementPlusResolver(),VantResolver()]
		}),

	],
	optimizeDeps: {
		include: ['schart.js']
	}
});
